home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / libsrc~1.z / libsrc~1 / memset.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-28  |  588 b   |  35 lines

  1. #include "lib.h"
  2.  
  3. /*
  4.  * memset - set bytes
  5.  *
  6.  * CHARBITS should be defined only if the compiler lacks "unsigned char".
  7.  * It should be a mask, e.g. 0377 for an 8-bit machine.
  8.  */
  9.  
  10. #ifndef CHARBITS
  11. #    define    UNSCHAR(c)    ((unsigned char)(c))
  12. #    define  uchar        unsigned char
  13. #else
  14. #    define    UNSCHAR(c)    ((c)&CHARBITS)
  15. #    define  uchar        char
  16. #endif
  17.  
  18. _VOIDSTAR
  19. memset(s, ucharfill, size)
  20. _VOIDSTAR s;
  21. register int ucharfill;
  22. _SIZET size;
  23. {
  24.     register uchar *scan;
  25.     register _SIZET n;
  26.     register int uc;
  27.  
  28.     scan = s;
  29.     uc = UNSCHAR(ucharfill);
  30.     for (n = size; n > 0; n--)
  31.         *scan++ = uc;
  32.  
  33.     return(s);
  34. }
  35.